package T31_T40;

import datastructure.TreeNode;
public class T39 {

    public boolean isSymmetric(TreeNode root) {
        if (root==null)return true;
        return checkTreeNode(root.left,root.right);

    }
    private boolean checkTreeNode(TreeNode left,TreeNode right){
        if (left==null&&right==null)return true;
        if (left==null||right==null)return false;
        return (left.val==right.val)&&
                checkTreeNode(left.left,right.right)&&
                checkTreeNode(left.right,right.left);
    }
}
